"use strict";
import * as React from 'react';
const { Image } = require('react-native');
const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
const { CachedImage, ImageCache, CachedImageBackground } = require('react-native-img-cache');
class MyImage extends React.Component {
    constructor() {
        super(...arguments);
        this.getStyle = () => {
            let styles = Object.assign({}, this.props.style);
            if (this.props.size) {
                if (typeof this.props.size === 'number') {
                    styles['width'] = this.props.size;
                    styles['height'] = this.props.size;
                }
                else {
                    styles = Object.assign({}, styles, this.props.size);
                }
            }
            return styles;
        };
        this.onLoadStart = (e) => {
        };
        this.onLoad = (e) => {
            if (this.props.onLoad) {
                this.props.onLoad(e);
            }
        };
        this.onLoadEnd = (e) => {
            if (this.props.onLoadEnd) {
                this.props.onLoadEnd(e);
            }
        };
    }
    render() {
        if (React.Children.count(this.props.children) > 0) {
            return <CachedImageBackground {...this.props} {...this.getStyle()}>{this.props.children}</CachedImageBackground>;
        }
        return (<CachedImage {...this.props} {...this.getStyle()}/>);
    }
}
MyImage.defaultProps = {
    canShowLightBox: true
};
export default MyImage;
